package mrusanov.ui

import battle.{ BattleContainerPanel, BattlePanel }
import java.util.Date
import management.buildings.BuildingsPanel
import management.staff.StaffPanel
import management.{ FinancePanel, CalendarPanel, TeamRosterPanel }
import mrusanov.team.Club
import mrusanov.season.WorldSeason
import newgame.NewGamePanel
import mrusanov.battle.Battle
import mrusanov.nation.World
import mrusanov.tournament.MatchInfo
import mrusanov.ui.stats.ResultsPanel

class PanelBuilder(mainFrame: MainFrame, world: World) {
	private def now = world.today
	private def club = world.userClub

	def results = new ResultsPanel(world)
	def firstTeam = new TeamRosterPanel(now, club.firstTeam)
	def secondTeam = new TeamRosterPanel(now, club.secondTeam)
	def juniorTeam = new TeamRosterPanel(now, club.juniorTeam)
	def transfers = throw new UnsupportedOperationException("Not implemented!")
	def calendar = new CalendarPanel(now, club, world.currentSeason)
	def infra = new BuildingsPanel(club)
	def finance = new FinancePanel
	def staff = new StaffPanel(now, club)
	def newGame = new NewGamePanel(mainFrame)
	def loadGame = throw new UnsupportedOperationException("Not implemented!")
	def saveGame = throw new UnsupportedOperationException("Not implemented!")
	def battlePanel(info: MatchInfo): BattleContainerPanel = {
		val battle = info.battle
		val userTeam = club.teams.filter(battle.tookPartInBattle)
		require(!userTeam.isEmpty)

		new BattleContainerPanel(mainFrame, battle, info, userTeam(0))
	}

	def nextEvent = new NextEventButton(mainFrame, world, this)
}
